package com.lagou.es.controller;

import com.lagou.common.pojo.Products;
import com.lagou.es.respository.ProductRepository;
import com.lagou.es.service.ProductsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class KafkaMessage {

    @Autowired
    private ProductsService productsService;

    @Autowired
    public ProductRepository productRepository;

    @KafkaListener(topics = "product")
    public void processMessage(Integer id) {
        System.out.println("id = " + id);

        Products products = productsService.selectById(id);
        System.out.println(products);

        productRepository.save(products);

    }

}
